const { mongoose } = require("../utils/mongoose");

const users = mongoose.Schema({
    username: { type: String, required: true },
    password: { type: String, required: true },
    mobile: { type: String },
    email: { type: String },
    nickname: { type: String },
    uid: { type: String, required: true },
    createTime: { type: String, required: true }
})

const Users = mongoose.model("users", users);


const regist = (data) => {
    const users = new Users(data);
    return users.save()
        .then(res => res)
        .catch(err => {
            console.log(err)
        })
}


const login = (data) => {
    return Users.find(data)
        .then(res => res)
        .catch(err => {
            console.log(err)
        })
}

module.exports = {
    regist,
    login
}